<?php
session_start();

define('DB_HOST',   'yallara.cs.rmit.edu.au:53936');
define('DB_NAME',   'happyendings');

define('DB_USER',   '');
define('DB_PW',     '');

if (!$dbconn = mysql_connect(DB_HOST, DB_USER, DB_PW)) {
  echo 'Could not connect to mysql on ' . DB_HOST . "\n";
  exit;
}

if (!mysql_select_db(DB_NAME, $dbconn)) {
  echo 'Could not use database ' . DB_NAME . "\n";
  echo mysql_error() . "\n";
  exit;
}


	$userid = $_SESSION['SESS_USER_ID'];
	$user_isbanned = $_SESSION['SESS_BANNED_ID'];
	$user_isadmin = $_SESSION['SESS_ADMIN_ID'];
	$user_isloggedin = $_SESSION['SESS_LOGGED_IN'];
	$userid = $_POST['userunsuspend'];


	if($user_isadmin == "Y")
	{
		$query = "UPDATE user SET is_banned='N' WHERE user_id = " . $userid;
	

		mysql_select_db("happyendings", $dbconn);
		$result = mysql_query($query, $dbconn);
		echo '<html><head><link href="template.css" type="text/css" rel="stylesheet" /><title>User Banned</title></head><body>User Banned<br /><a href="admin_form.php">Go Back</a> </body></html> ';
		exit;
	}
	else
	{
		echo '<html><head><link href="template.css" type="text/css" rel="stylesheet" /><title>Failed</title></head><body> Not admin! <br /><a href="index.php">Go Back</a> </body></html> ';
		exit;
	}
	
?>
